figure(1);
time = [0 0 2 2 2 3 4 4 4 5 ];
power = [9 9 21 21 21 13 4 4 4 0 ];
stairs(time, power, 'k-');
line('XData', [0, 5], 'YData', [27, 27], 'LineStyle', '--', 'LineWidth', 2, 'Color','b');
axis([0 5 0 30]);
legend('P(t)', 'Pmax');
xlabel('Time (seconds)');
ylabel('Power Consumed (watts)');
title('Power Consumed vs. Time');
